<?php
vendor ( 'weibooauth' ); //导入微波验证类库
class IndexAction extends Action {
	/**
    +----------------------------------------------------------
	 * 默认操作
    +----------------------------------------------------------
	 */
	public function index() {
		//    	echo 'hello!';
		$o = new WeiboOAuth ( C ( 'WB_AKEY' ), C ( 'WB_SKEY' ) );
		$keys = $o->getRequestToken ();
		//$aurl = $o->getAuthorizeURL( $keys['oauth_token'] ,false , $_SERVER['SCRIPT_URI'].'/callback.php');
		$aurl = $o->getAuthorizeURL ( $keys ['oauth_token'], false, C('SITE_HOST') . U ( 'Index/callback' ) );
		$_SESSION ['keys'] = $keys;
		$this->assign ( 'aurl', $aurl );
		$this->display ();
	}
	/**
	 * 新浪微波验证回调函数
	 */
	public function callback() {
		$o = new WeiboOAuth ( C ( 'WB_AKEY' ), C ( 'WB_SKEY' ), $_SESSION ['keys'] ['oauth_token'], $_SESSION ['keys'] ['oauth_token_secret'] );
		$last_key = $o->getAccessToken ( $_REQUEST ['oauth_verifier'] );
		$_SESSION ['last_key'] = $last_key;
		$this->display ();
	}
	/**
	 * 空操作
	 */
	Public function _empty() {
		R ( 'Empty', 'index' );
	}
}
?>